<template>
  <div class="home-container">
    <div class="module-grid">
      <el-card
        v-for="(module, index) in modules"
        :key="index"
        :class="['module-card', `module-${index + 1}`]"
        shadow="hover"
        @click="handleModuleClick(module.path)"
      >
        <div class="module-content">
          <el-icon :size="40" :class="module.icon"></el-icon>
          <h3>{{ module.title }}</h3>
          <p>{{ module.description }}</p>
        </div>
      </el-card>
    </div>

    <div class="feature-sections">
      <el-card class="feature-card" shadow="hover">
        <template #header>
          <div class="card-header">
            <h3>数据统计</h3>
            <el-button class="button" text>查看更多</el-button>
          </div>
        </template>
        <div class="statistics-content">
          <div class="stat-item">
            <h4>今日回收量</h4>
            <p class="stat-value">0 kg</p>
          </div>
          <div class="stat-item">
            <h4>本月回收量</h4>
            <p class="stat-value">0 kg</p>
          </div>
        </div>
      </el-card>

      <el-card class="feature-card" shadow="hover">
        <template #header>
          <div class="card-header">
            <h3>回收动态</h3>
            <el-button class="button" text>查看更多</el-button>
          </div>
        </template>
        <div class="news-content">
          <p class="empty-text">暂无动态</p>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'


const router = useRouter()

const modules = ref([
  {
    title: '站点列表',
    description: '查看垃圾分类实时数据',
    icon: 'Monitor',
    path: '/station-list'
  },
  {
    title: '数据分析',
    description: '回收数据统计分析',
    icon: 'DataLine',
    path: '/analysis'
  },
  {
    title: '个人中心',
    description: '环保贡献详细查看',
    icon: 'Management',
    path: '/management'
  },
  {
    title: '设置中心',
    description: '个性化设置和系统配置',
    icon: 'Setting',
    path: '/settings'
  }
])

const handleModuleClick = (path) => {
  router.push(path)
}
</script>

<style scoped>
.home-container {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.module-card {
  cursor: pointer;
  transition: transform 0.3s ease;
}

.module-card:hover {
  transform: translateY(-5px);
}

.module-content {
  text-align: center;
  padding: 1.5rem;
}

.module-1 { background-color: #ecf5ff; }
.module-2 { background-color: #f0f9eb; }
.module-3 { background-color: #fdf6ec; }
.module-4 { background-color: #fef0f0; }

.module-content h3 {
  margin: 1rem 0 0.5rem;
  font-size: 1.25rem;
  color: #303133;
}

.module-content p {
  color: #606266;
  margin: 0;
}

.feature-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.feature-card {
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #303133;
}

.statistics-content {
  display: flex;
  justify-content: space-around;
  padding: 1rem 0;
}

.stat-item {
  text-align: center;
}

.stat-item h4 {
  margin: 0 0 0.5rem;
  color: #606266;
  font-weight: normal;
}

.stat-value {
  font-size: 1.5rem;
  color: #409EFF;
  margin: 0;
}

.news-content {
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-text {
  color: #909399;
}

@media (max-width: 768px) {
  .home-container {
    padding: 1rem;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .feature-sections {
    grid-template-columns: 1fr;
  }
}
</style>